

if(SG_BUILD_DOCUMENTATION)
  
  if(COMMAND CMAKE_POLICY)
  if(POLICY CMP0135)
    cmake_policy(SET CMP0135 NEW)
  endif()
  endif(COMMAND CMAKE_POLICY)
  include(FetchContent)
  
  FetchContent_Declare(
      doxygen-awesome-css
      URL https://github.com/jothepro/doxygen-awesome-css/archive/refs/heads/main.zip
  )
  FetchContent_MakeAvailable(doxygen-awesome-css)

  FetchContent_GetProperties(doxygen-awesome-css SOURCE_DIR AWESOME_CSS_DIR)

  # 查找 Doxygen 程序
  find_package(Doxygen)

  if(DOXYGEN_FOUND)
      # 指定 Doxygen 配置文件的位置
      set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/Resource/config/Doxyfile.in)
      set(DOXYGEN_OUT ${CMAKE_BINARY_DIR}/Doxyfile)

      configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT})

      add_custom_target(Document
          COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
          WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
          COMMENT "Generating API documentation with Doxygen"
          VERBATIM
      )
  endif()

endif(SG_BUILD_DOCUMENTATION)
